package com.example.boot.controller;

import cn.hutool.core.lang.copier.Copier;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.Result;
import com.example.pojo.entity.Inbound;
import com.example.pojo.entity.Inventory;
import com.example.pojo.entity.Warehouse;
import com.example.service.IInboundService;
import com.example.service.IInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @author wy
 * @since 2024/7/18
 */

@RestController
@RequestMapping("/inbound")
@Api(tags = "物资入库接口")
@Slf4j
public class InboundController {

    @Autowired
    private IInboundService iInboundService;

    /**
     * 分页查询
     */
    @ApiOperation("分页展示入库信息列表")
    @GetMapping("/selectPage")
    public Result selectPage(Inbound inbound,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        Page<Inbound> page = iInboundService.selectPage(inbound, pageNum, pageSize);
        return Result.success(page);
    }

    @ApiOperation("物资入库")
    @PostMapping("/add")
    public Result add(@RequestBody Inbound inbound){
        iInboundService.add(inbound);
        return Result.success(inbound);
    }

    @ApiOperation("修改入库信息")
    @PutMapping("/update")
    public Result update(@RequestBody Inbound inbound){
        iInboundService.updateById(inbound);
        return Result.success();
    }
}
